/*
 ------------------------------------------------------------------------------
 Copyright (C) 2013 Eternal Games.

 This file is part of the GLQuake source code.

 The GLQuake source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The GLQuake source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the GLQuake source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


//
// cg_commands.cpp - operator commands
//


#include "cg_local.h"


/*
 ==================
 CG_Where_f
 ==================
*/
static void CG_Where_f (){

	G_Printf("%s : %s\n", cg.renderView.origin.ToString(0), cg.renderViewAngles.ToString(0));
}

/*
 ==================
 CG_SizeUp_f
 ==================
*/
static void CG_SizeUp_f (){

	glqCVarSystem->SetInteger(cg_viewSize, cg_viewSize->integerValue + 10);
}

/*
 ==================
 CG_SizeDown_f
 ==================
*/
static void CG_SizeDown_f (){

	glqCVarSystem->SetInteger(cg_viewSize, cg_viewSize->integerValue - 10);
}


// ============================================================================


/*
 ==================

 ==================
*/
void CG_AddCommands (){

	// Add commands
	glqCmdSystem->AddCommand("testModel", CG_TestModel_f, "Tests a model", glqCmdSystem->ArgCompletion_ModelName);
	glqCmdSystem->AddCommand("testGun", CG_TestGun_f, "Tests the current test model as a gun model", NULL);
	glqCmdSystem->AddCommand("testMaterial", CG_TestMaterial_f, "Tests a material on the current test model", glqCmdSystem->ArgCompletion_MaterialName);
	glqCmdSystem->AddCommand("testMaterialParm", CG_TestMaterialParm_f, "Tests a material parm on the current test model", NULL);
	glqCmdSystem->AddCommand("testRemoteView", CG_TestRemoteView_f, "Tests a remote view on the current test model", NULL);
	glqCmdSystem->AddCommand("firstFrame", CG_FirstFrame_f, "Jumps to the first animation frame on the current test model", NULL);
	glqCmdSystem->AddCommand("lastFrame", CG_LastFrame_f, "Jumps to the last animation frame on the current test model", NULL);
	glqCmdSystem->AddCommand("prevFrame", CG_PrevFrame_f, "Jumps to the previous animation frame on the current test model", NULL);
	glqCmdSystem->AddCommand("nextFrame", CG_NextFrame_f, "Jumps to the next animation frame on the current test model", NULL);
	glqCmdSystem->AddCommand("jumpToFrame", CG_JumpToFrame_f, "Jumps to the specified animation frame on the current test model", NULL);	
	glqCmdSystem->AddCommand("testSound", CG_TestSound_f, "Tests a sound", glqCmdSystem->ArgCompletion_SoundShaderName);
	glqCmdSystem->AddCommand("testSoundParm", CG_TestSoundParm_f, "Tests a sound parm on the current test sound", NULL);
	glqCmdSystem->AddCommand("testPostProcess", CG_TestPostProcess_f, "Tests a post-process material", glqCmdSystem->ArgCompletion_MaterialName);
	glqCmdSystem->AddCommand("testPostProcessParm", CG_TestPostProcessParm_f, "Tests a material parm on the current test post-process", NULL);
	glqCmdSystem->AddCommand("testDecal", CG_TestDecal_f, "Tests a decal", glqCmdSystem->ArgCompletion_MaterialName);
	glqCmdSystem->AddCommand("testSplatDecal", CG_TestSplatDecal_f, "Tests a splat decal", glqCmdSystem->ArgCompletion_MaterialName);
	glqCmdSystem->AddCommand("where", CG_Where_f, "Shows the current view position and angles", NULL);
	glqCmdSystem->AddCommand("sizeUp", CG_SizeUp_f, "Expands the game view", NULL);
	glqCmdSystem->AddCommand("sizeDown", CG_SizeDown_f, "Shrinks the game view", NULL);

	// Commands forwarded to the server
	glqCmdSystem->AddCommand("god", NULL, "Toggles god mode on/off", NULL);
	glqCmdSystem->AddCommand("noClip", NULL, "Toggles noClip mode on/off", NULL);
	glqCmdSystem->AddCommand("give", NULL, "Gives the desired item", NULL);
	glqCmdSystem->AddCommand("kill", NULL, "Kills the player", NULL);
	glqCmdSystem->AddCommand("say", NULL, "Text chat", NULL);
	glqCmdSystem->AddCommand("sayTeam", NULL, "Team text chat", NULL);
}

/*
 ==================

 ==================
*/
void CG_RemoveCommands (){

	// Remove commands
	glqCmdSystem->RemoveCommand("testModel");
	glqCmdSystem->RemoveCommand("testGun");
	glqCmdSystem->RemoveCommand("testMaterial");
	glqCmdSystem->RemoveCommand("testMaterialParm");
	glqCmdSystem->RemoveCommand("testRemoteView");
	glqCmdSystem->RemoveCommand("firstFrame");
	glqCmdSystem->RemoveCommand("lastFrame");
	glqCmdSystem->RemoveCommand("prevFrame");
	glqCmdSystem->RemoveCommand("nextFrame");
	glqCmdSystem->RemoveCommand("jumpToFrame");
	glqCmdSystem->RemoveCommand("testSound");
	glqCmdSystem->RemoveCommand("testSoundParm");
	glqCmdSystem->RemoveCommand("testPostProcess");
	glqCmdSystem->RemoveCommand("testPostProcessParm");
	glqCmdSystem->RemoveCommand("testDecal");
	glqCmdSystem->RemoveCommand("testSplatDecal");
	glqCmdSystem->RemoveCommand("where");
	glqCmdSystem->RemoveCommand("sizeUp");
	glqCmdSystem->RemoveCommand("sizeDown");

	// Commands forwarded to the server
	glqCmdSystem->RemoveCommand("noClip");
	glqCmdSystem->RemoveCommand("give");
	glqCmdSystem->RemoveCommand("kill");
	glqCmdSystem->RemoveCommand("say");
	glqCmdSystem->RemoveCommand("sayTeam");
}